package com.vehicle.mq;

import com.vehicle.common.redis.manager.CacheManager;
import com.vehicle.mq.queue.EventQueue;
import com.vehicle.mq.worker.EventWorker;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by yantingbin on 2017/12/7.
 */
@Configuration
public class EventConfigure {
    @Bean
    @ConditionalOnMissingBean(name = "eventWorker")
    public EventWorker eventWorker(EventQueue eventQueue) {
        EventWorker eventWorker = new EventWorker(eventQueue);
        eventWorker.init();
        return eventWorker;
    }

    @Bean
    @ConditionalOnMissingBean(name = "eventQueue")
    public EventQueue eventQueue(CacheManager cacheManager) {
        EventQueue eventQueue = new EventQueue(cacheManager);
        return eventQueue;
    }
}
